<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/style.css">
    <title></title>
</head>
<style>
    .content{
        background: url("./img/1.png") no-repeat;
    }
</style>
<body>
<div class="box">
    <div class="content">
        <div class="login-wrapper">
            <h1>登录</h1>
            <div class="login-form">
                <div class="username form-item">
                    <span>请输入工号</span>
                    <input type="text" class="input-item"/>
                </div>
                <div class="password form-item">
                    <span>密码</span>
                    <input type="password" class="input-item"/>
                </div>
                <button type="button" class="login-btn">登 录</button>
            </div>
            <div class="divider">
                <span class="line"></span>
                <span class="divider-text">其他方式登录</span>
                <span class="line"></span>
            </div>
            <div class="other-login-wrapper">
                <div class="other-login-item">
                    <img src="./img/QQ.png" alt="">
                </div>
                <div class="other-login-item">
                    <img src="./img/WeChat.png" alt="">
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="js/jquery-1.12.4.js"></script>
<script>
        $('.login-btn').click(function () {
            var name = $('.username input').val();
            var pwd = $('.password input').val();
            var employee = {};
            employee["employeeid"] = name;
            employee["password"] = pwd;
            $.ajax({
                url: `http://localhost:8080/jboa/api/employee/login`,
                dataType: "json",
                type: "post",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(employee),
                success: function (data) {
                    if (data.code != null) {
                        sessionStorage.setItem("eid", data.id);
                        window.location.href = "main.html";
                    } else {
                        alert("用户名或密码错误");
                    }
                }
            })
        })
</script>
</html>